package cn.kgc.springcloud.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: mosin
 * @version: v1.0  2022/6/11
 */
@RestController
@RequestMapping("/hystrix")
public class HystrixController {

    @RequestMapping("/h1")
    @HystrixCommand(fallbackMethod = "test01FallbackMethod")
    public String test01( Integer id){
        //根据参数的不同  模拟异常的发生
        if(id<0){
            int a = 1/0;
        }
        return "hystrix ok";
    }

    public  String test01FallbackMethod(Integer id){
        return "当前的服务不可用,可能被熔断了!!";
    }
}
